Ajax + PHP create progress bar code [readyState status description]

  • 2020-03-31 20:38:04
  • OfStack

ReadyState == state (0,1,2,3,4)
0: the request is not initialized and open is not called
1: the request has been set up, but it has not been sent, and send has not been called
2: the request has been sent and is being processed
3: the request is being processed, usually with some data already available in the response
After 4:
 
var xmlHttp; 
function create() 
if(window.ActiveXObject) 
{ 
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");//IE browser
} 
else if(window.XMLHttpRequest) 
{ 
xmlHttp = new XMLHttpRequest();// non IE browser
} 
} 
function Request(url) 
{ 
xmlHttp.open("GET","for.php?id="+url,true);//True is asynchronous
xmlHttp.onreadystatechange = ip985;//Response function
xmlHttp.send(null); 
} 
function ip985() 
{ 
if(xmlHttp.readyState==1) 
{ 
document.getElementById('IP985').innerHTML = " Request established, ready to send... "; //IP985 flags
} 
if(xmlHttp.readyState==4) 
{ 
var v = xmlHttp.responseText;//Access to content
document.getElementById('ip985').innerHTML = v;//Target web content
} 
} 

Related articles: